package com.unieagle.exam.db;

import java.io.File;

import android.content.Context;
import android.content.ContextWrapper;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DatabaseContext extends ContextWrapper {        
    
    public DatabaseContext(Context base){
        super(base);
    }
 
    @Override
    public File getDatabasePath(String name) {
        String dbPath = this.getCacheDir() + "/exam.db";//数据库路径
        File dbFile = new File(dbPath);
        return dbFile;
    }
    
    @Override
    public SQLiteDatabase openOrCreateDatabase(String name, int mode, 
            SQLiteDatabase.CursorFactory factory) {
        SQLiteDatabase result = SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), null);
        return result;
    }
 
    @Override
    public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory,
            DatabaseErrorHandler errorHandler) {
        SQLiteDatabase result = SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), null);
        return result;
    }
} 